import time
from Common.Base import Base,open_browser

'''
Author:牟星林
'''

admin_our = ("http://localhost:8080/Ecshop/admin/privilege.php?act=login")
class SearchOrder(Base):

    in_order = ("id","order_sn")
    c_search =("css selector","body > div.form-div > form > input.button")
    c_cancel = ("css selector","#panelCloud > div.panel-cross > span")
    c_ecshop =("id","cloudLogin")
    in_username = ("name","username")
    in_password = ("name","password")
    c_login = ("class name","btn-a")
    frameset = ("id","frame-body")
    frame = ("id","menu-frame")
    c_admin_order = ("class name","icon-order")
    c_radio = ("name","checkboxes")


    def input_order(self,order):
        '''
        输入订单号
        :return:
        '''
        self.send_keys(self.in_order,order)

    def click_search(self):
        '''
        点击搜索
        :return:
        '''
        self.click(self.c_search)

    def click_cancel(self):
        '''
        点击关闭弹窗
        :return:
        '''
        self.click(self.c_cancel)

    def click_ecshop(self):
        '''
        点击ecshop
        :return:
        '''
        self.click(self.c_ecshop)

    def input_username(self,username):
        '''
        输入用户名
        :param username:
        :return:
        '''
        self.send_keys(self.in_username,username)

    def input_password(self,password):
        '''
        输入密码
        :param password:
        :return:
        '''
        self.send_keys(self.in_password,password)

    def click_login(self):
        '''
        点击登录
        :return:
        '''
        self.click(self.c_login)

    def iframe(self,num):
        '''
        进入页面嵌套
        :return:
        '''
        self.driver.switch_to.frame(num)

    def pass_ifeame(self):
        '''
        退出页面嵌套
        :return:
        '''
        self.driver.switch_to_default_content()


    def click_admin_order(self):
        '''
        点击订单管理
        :return:
        '''
        self.click(self.c_admin_order)

    def click_radio(self):
        '''
        点击订单号的单选框
        :return:
        '''
        self.click(self.c_radio)


if __name__ == '__main__':
    driver = open_browser()
    search =SearchOrder(driver)
    search.open_url("http://localhost:8080/Ecshop/admin/privilege.php?act=login")
    driver.maximize_window()

    search.click_cancel()

    search.click_ecshop()

    search.input_username("admin")
    search.input_password("mxl779208546")

    search.click_login()


    search.iframe(0)
    search.click_admin_order()
    search.pass_ifeame()



    search.iframe(2)
    search.input_order(2023020586700)

    time.sleep(3)
    search.click_search()

    search.click_radio()



    time.sleep(3)
    search.close_browser()






























